<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>垃圾箱</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" href="styles/jquery-ui-1.8.13.custom.css"
			type="text/css"></link>
		<link rel="stylesheet" href="styles/list.css" type="text/css"></link>
		<link rel="stylesheet" href="tools/dataTable/css/demo_table_jui.css"
			type="text/css"></link>

		<script type="text/javascript" src="js/jquery.js">
</script>
		<script type="text/javascript" src="js/jquery-ui-1.8.13.custom.min.js">
</script>
		<script type="text/javascript"
			src="tools/dataTable/js/jquery.dataTables.js">
</script>
		<script type="text/javascript"
			src="js/mailListTable.js">
</script>
		<script type="text/javascript">
$(document).ready(function() {
				var userId = <s:property value="userId" />;
				
				$("#selectAll").click(function() { 
					var state = $(this).attr("checked");
					$("input[name='recordIds']").attr("checked", state);					
				});
				
				$("input[name='delete']").click(function(){
					var selectedIds = new Array();
					var recordIdsDom = $.grep( $("input[name='recordIds']"), function(dom,i){
					  return $(dom).attr("checked");
					});
					if(recordIdsDom.length == 0){
						alert("请选择要删除的邮件");
					}
					for(i=0; i<recordIdsDom.length; i++){
						selectedIds[i] = $(recordIdsDom[i]).val();						
					}
					$.ajax({
						"type":'POST',
						"url":"deleteSelected.action?selectedIds="+selectedIds+"&fromOrTo=To",
						"success":function(){	
							location=location; 	
						}
					})
				});
				
				var oTable = $('#maillist').dataTable( {
					"bJQueryUI" : true,
					"bFilter" : false,
					"bAutoWidth" : false,
					"iDisplayLength" : 10,		
					"bPaginate" : true,
					"sPaginationType" : "full_numbers",
					"bProcessing" : true,
					"bServerSide" : true,
					"sAjaxSource" : "showRecyclebinTable.action",
					"fnServerData" : function(sSource, aoData, fnCallback) {						
						$.ajax( {
							"dataType" : 'json',
							"type" : 'POST',
							"url" : sSource + "?userId=" + userId,
							"data" : aoData,
							"success" : function(html){
								fnCallback(html);
								fnAddHover(4);
								fnAddClick();
							}
							
												
						});
						//绑定事件
						
					},		
					"aoColumnDefs": [
								{ "sClass": "dataCell", "aTargets": [ "_all" ] },
								{ "bSortable": false, "aTargets": [ 0 ] }
							],
					"aaSorting" : [],
					"oLanguage" : {
						"sProcessing" : "查询中...",
						"sLengthMenu" : "每页 _MENU_ 条记录 ",
						"sZeroRecords" : "没有数据",
						"sEmptyTable" : "没有数据",
						"sInfo" : "显示_TOTAL_ 条记录中的 _START_ 到 _END_ 条",
						"sInfoEmpty" : "显示0 条记录",
						"sInfoFiltered" : "",
						"oPaginate" : {
							"sFirst" : "首页",
							"sPrevious" : "上一页",
							"sNext" : "下一页",
							"sLast" : "尾页"
						}
					}
			
				});
				
							
		});
		</script>
	</head>

	<body>
		<input class="btn" type="button" name="delete" class="normal" value="彻底删除" />
		&nbsp;&nbsp;
		<br/><br/>		
		<table id="maillist" cellpadding="0" cellspacing="0" border="1"
			class="display" bordercolor="#FFFFFF" style="table-layout: fixed;">
			<thead>
				<tr>
					<th class="headerCell" width="80px">
						<input type="checkbox" id="selectAll" name="selectAll"
							title="选中/取消选中" />
					</th>					
					<th class="headerCell">
						发件人
					</th>					
					<th class="headerCell">
						主题
					</th>
					<th class="headerCell">
						发送日期
					</th>
				</tr>
			</thead>
			<tbody>

			</tbody>
		</table>
		<br/><br/>
		<input class="btn" type="button" name="delete" class="normal" value="彻底删除" />
		&nbsp;&nbsp;		
	</body>
</html>
